//
//  JOKECell.m
//  NEWS
//
//  Created by lanou on 16/4/9.
//  Copyright © 2016年 孙金龙. All rights reserved.
//

#import "JOKECell.h"

@implementation JOKECell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _author = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, KWidth, 25)];
        _author.textColor = [UIColor grayColor];
        _author.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_author];
        
        _time = [[UILabel alloc] initWithFrame:CGRectMake(5, 25, KWidth, 20)];
        _time.font = [UIFont systemFontOfSize:12];
        _time.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_time];
        
        _detail = [[UILabel alloc] initWithFrame:CGRectMake(5, 55, KWidth-10, 100)];
        _detail.font = [UIFont systemFontOfSize:14];
        _detail.numberOfLines = 0;
        [self.contentView addSubview:_detail];
    }
    return self;
}


- (void)setModel:(JOKEModel *)model
{
    _author.text = model.name;
    _time.text = model.passtime;
    _detail.text = model.text;
    CGSize size = CGSizeMake(KWidth-10, 1000);
    CGRect lable = [model.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
    _detail.frame = CGRectMake(5, 55, KWidth-10, lable.size.height);
}

// cell 的高度
+ (CGFloat )HeightForCellWith:(JOKEModel *)model
{
    CGSize size = CGSizeMake(KWidth-10, 1000);
    CGRect lable = [model.text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
    NSLog(@"=====%f",lable.size.height);
    return lable.size.height+75;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
